package com.zhengke.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageInfo;
import com.zhengke.common.dao.CommonDao;
import com.zhengke.common.object.Result;
import com.zhengke.pojo.BannerPhone;
@Service
public class BannerPhoneServiceImpl implements BannerPhoneService{
    /**
     * ssx
     * */
	@Autowired
	private CommonDao dao;

	@Override
	public Result queryPhones(Integer imgClass) throws Exception {
		Map<String,Integer> param = new HashMap<String,Integer>();
		param.put("imgClass", imgClass);
		List<BannerPhone> rtnList = (List<BannerPhone>)dao.findForList("BannerPhoneMapper.queryPhone", param);
        PageInfo<BannerPhone> pageInfo = new PageInfo<BannerPhone>(rtnList);
		
		Result rs = new Result();
		rs.setCode("0");
		rs.setCount(pageInfo.getTotal());
        rs.setData(rtnList);		
		return rs;
		
	}

	@Override
	public Result updatePhones(Integer id, String imgAddress) throws Exception {
		Map<String,Object> param = new HashMap<String,Object>();
		param.put("id", id);
		param.put("imgAddress", imgAddress);
		int a = dao.update("BannerPhoneMapper.updatePhones", param);
		String b = String.valueOf(a);
		Result rs = new Result();
		rs.setCode(b);
		return rs;
	}
	

}
